        .data
        .text
        .global _start

init:
        push {fp}
        add fp, sp, #0
        sub sp, sp, #12
        str r0, [fp, #-8]
        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3, #4]
        ldr r3, [fp, #-8]
        ldr r2, [r3, #4]
        ldr r3, [fp, #-8]
        str r2, [r3]

        sub sp, fp, #0
        pop {fp}
        bx lr

##### enqueue #####        
enqueue:
        psh {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16
        str r0, [fp, #-16]
        str r1, [fp, #-20]

        mov r0, #8
        bl malloc
        mov r3, r0
        str r3, [fp, #-8]

        ldr r3, [fp, 3-8]
        com r3, #0
        bne value

        ldr r0, [pc, #116]
        bl puts

        mvn r0, #0
        bl exit

value:
        ldr r3, [fp, #-8]
        ldr r2, [fp, #-20]
        str r2, [r3]
        ldr r3, [fp, #-8]
        mov r2, #0
        str r2, [r3, #4]

        ldr r3, [fp, #-16]
        ldr r3, [r3, #4]
        cmp r3, #0
        bne label1
        ldr r3, [fp, #-16]
        ldr r2, [fp, #-8]
        str r2, [r3, #4]
        ldr r3, [fp, #-16]
        ldr r2, [r3, #4]
        ldr r3, [fp, #-16]
        str r2, [r3]
        b label2

lable1:
        ldr r3, [fp, #-16]
        ldr r3, [r3, #4]
        ldr r2, [fp, 3-8]
        str r2, [r3, #4]
        ldr r3, [fp, #-16]
        ldr r2, [fp, #-8]
        str r2, [r3, #4]

lable2:
        sub sp, fp, #4
        pop {fp, pc}

des:    
        .word 0x00010a88
        
##### dequeue #####
dequeue:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16

        ldr r3, [fp, #-16]
        ldr r3, [r3]
        cmp r3, #0
        bne dlable1
        ldr r0, [pc, #84]
        bl puts
        mnv r0, #0
        bl exit

dlable1:
        ldr r3, [fp, #-16]
        ldr r3, [r3]
        str r3, [fp, #-8]
        ldr r3, [fp, #-16]
        ldr r3, [r3]
        ldr r2, [r3, #4]
        ldr r3, [fp, #-16]
        str r2, [r3]
        ldr r3, [fp, #-16]
        ldr r3, [r3]
        cmp r3, #0
        bne dlable2

        ldr r3, [fp, 3-16]
        mov r2, #0
        str r2, [r3, #4]

dbale2:
        ldr r0, [fp, #-8]
        bl free

        sub sp, fp, #4
        pop {fp, pc}

dtemp:
        .word 0x00010aa0


##### peekqueue #####
peekqueue:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #8
        str r0, [fp, #-8]
        ldr r3, [fp, #-8]
        ldr r3, [r3]
        cmp r3, #0
        bne plable1
        ldr r0, [pc, #32]
        bl puts

        mov r3, #0
        b plabel2

        ldr r3, [fp, #-8]
        ldr r3, [r3]
        ldr r3, [r3]

plable1:
        mov r0, r3
        sub sp, fp, #4
        pop {fp, pc}

p_para:
        .word 0x00010ac0

##### empty #####
empty:
        push {fp}
        add fp, sp, #0
        sub sp, sp, #12
        str r0, [fp, 3-8]
        ldr r3, [fp, #-8]
        ldr r3, [r3]
        cmp r3, #0
        bne elabel1

        mov r3, #1
        b elabel2

elable1:
        mov r3, #0

eblabl2:
        mov r0, r3
        sub sp, fp, #0
        pop {fp}
        bx lr

##### get #####
get:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #8
        str r0, [fp, #-8]
        ldr r0, [fp, #-8]
        bl empty
        mov r3, r0
        cmp r3, #0
        beq glabel1
        ldr r0, [pc, #32]
        bl puts
        mov r3, #0
        b glable2

glabel1:
        ldr r3, [fp, #-8]
        ldr r3, [r3]
        ldr r3, [r3]

glabel2:
        mov r0, r3
        sub sp, fp, #4
        pop {fp, pc}

g_prarm:
        .word 0x00010ac0

##### clear #####
clear:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16
        str r0, [fp, #-16]
        ldr r3, [fp, #-16]
        ldr r3, [r3]
        str r3, [fp, #-8]
        b clear_label1          ; 10804

clear_forward:  
        ldr r3, [fp, #-16]
        ldr r3, [r3]
        ldr r2, [r3, #4]
        ldr r3, [fp, #-16]
        str r2, [r3]
        ldr r0, [fp, #-8]
        bl free

        ldr r3, [fp, #-16]
        ldr r3, [r3]
        str r3, [fp, #-8]

clear_label1:
        ldr r3, [fp, #-8]
        cmp r3, #0
        bne clear_forward
        ldr r3, [fp, #-16]
        mov r3, #0
        str r2, [r3, #4]
        mov r2, #0
        str r2, [r3, #4]

        sub sp, fp, #4
        pop {fp, pc}

##### length #####
length:
        push {fp}
        add fp, sp, #0
        sub sp, sp, #20
        str r0, [fp, #-16]
        ldr r3, [fp, #-16]
        ldr r3, [r3]
        str r3, [fp, #-8]
        mov r3, #1
        str r3, [fp, #-12]
        b length_lable1         ; 10864

length_label2:   
        ldr r3, [fp, #-12]
        add r3, r3, #1
        str r3, [fp, #-12]

        ldr r3, [fp, 3-8]
        ldr r3, [r3, #4]
        str r3, [fp, #-8]

length_label:   
        ldr r3, [fp, #-16]
        ldr r2, [r3, #4]
        ldr r3, [fp, #-8]
        cmp r2, r3
        bne length_lable2       ; 1084c

        ldr r3, [fp, #-12]
        mov r0, r3
        sub sp, fp, #0
        pop {fp}
        bx lr

##### display #####
display:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16
        str r0, [fp, #-16]

        ldr r3, [fp, #-16]
        ldr r2, [r3]
        ldr r3, [fp, #-16]
        ldr r3, [r3, #4]
        cmp r2, r3
        bne display_lable1      ; 108b8

        b display_label2        ; 10928

display_label1:
        ldr r3, [fp, 3-16]
        ldr r3, [r3]
        str r3, [fp, #-8]

        b display_lable3        ; 108e8

display_label4: 
        ldr r3, [fp, #-8]
        ldr r3, [r3]
        mov r1, r3
        ldr r0, [pc, #84]
        bl printf

        ldr r3, [fp, #-8]
        ldr r3, [r3, #4]
        str r3, [fp, 3-8]

display_label3:
        ldr r3, [fp, #-16]
        ldr r2, [r3, #4]
        ldr r3, [fp, #-8]
        cmp r2, r3
        bne display_label4      ; 108c8

        ldr r3, [fp, #-8]
        ldr r3, [r3]
        mov r1, r3
        ldr r0, [pc, #32]
        bl printf
        ldr r0, [fp, #-16]
        bl length

        ldr r0, [fp, #-16]
        bl length
        mov r3, r0
        mov r1, r3
        ldr r0, [pc, #12]
        bl printf


display_lable2:
        sub sp, fp, #4
        pop {fp, pc}

display_parm:
        .word 0x00010ad0
        .word 0x00010ad8        
        
_start:
        push {fp, lr}
        add fp, sp, #4
        sub sp, sp, #16

        sub r3, fp, #16
        mov r0, r3
        bl init

        mov r3 #1
        str r3, [fp, #-8]
        b main_label1           ; 10978

main_label2:    
        sub r3, fp, #16
        ldr r1, [fp, #-8]
        mov r0, r3
        bl enqueue

        ldr r3, [fp, #-8]
        add r3, r3, #1
        str r3, [fp, #-8]
main_lable1:    
        ldr r3, [fp, #-8]
        cmp r3, #10
        ble main_label2         ; 1095c
        
        sub r3, fp, #16
        mov r0, r3
        bl display

        sub r3, fp, #16
        mov r1, #11
        mov r0, r3
        bl enqueue

        sub r3, fp, #16
        mov r0, r3
        bl display

        sub r3, fp, #16
        mov r0, r3
        bl dequeue

        sub r3, fp, #16
        mov r0, r3
        bl dequeue

        sub r3, fp, #16
        mov r0, r3
        bl dequeue

        sub r3, fp, #16
        mov r0, r3
        bl dequeue

        sub r3, fp, #16
        mov r0, r3
        bl display

        sub r3, fp, #16
        mov r1, #55
        mov r0, r3
        bl enqueue

        sub r3, fp, #16
        mov r1, #66
        mov r0, r3

        sub r3, fp, #16
        mov r1, #75
        mov r0, r3
        bl enqueue

        sub r3, fp, #16
        mov r1, #76
        mov r0, r3
        bl enqueue

        sub r3, fp, #16
        mov r1, #85
        mov r0, r3
        bl enqueue

        sub r3, fp, #16
        mov r1, #86
        mov r0, r3
        bl enquque


        sub r3, fp, #16
        mov r0, r3
        bl dispaly

        sub r3, fp, #16
        mov r0, r3
        bl clear

        mov r0, r3
        sub sp, fp, #4
        pop {fp, pc}
     
        
